@extends('default.layouts.companyPublic')

@section('title', '会员启停功能')
@section('headcss')
    @parent
    <link rel="stylesheet" href="{{asset('/default/css/company/list.css')}}">
@endsection
@section('rightcon')
    <div class="right">
        <!--菜单-->
        <div class="jright">
            <div class="content">
                <div class="jobtitle">
                    <div class="tithead">
                        <ul>
                            <li><a href="{{ route('myOrder.index') }}">我的套餐</a></li>
                            <li><a href="{{ route('myOrder.list') }}">我的定单</a></li>
                            <li><a href="{{ url('company/member_records') }}">会员记录</a></li>
                            @if(!empty(auth()->guard('company')->user()->stop_number))
                                <li class="active"><a href="{{ url('company/start_stop') }}">会员启停</a></li>
                            @endif
                        </ul>
                    </div>
                </div>
                {{--显示列表--}}
                <div class="pinfo">
                    {{--启停功能--}}
                    <div class="start_stop">

                        @if(auth()->guard('company')->user()->viptime > date('Y-m-d H:i:s',time()))
                            <span class="status"><a class="stop" onclick="startStop('你确定要关闭会员吗？',0)">关闭会员</a></span>
                            <span class="remaining">剩余启停次数<strong>{{auth()->guard('company')->user()->stop_number}}</strong>次</span>
                            <span class="remaining">你的会员期限是：<strong>{{auth()->guard('company')->user()->viptime}}</strong></span>
                        @else
                            <span class="status"><a class="start" onclick="startStop('你确定要开启会员吗？',1)">开启会员</a></span>
                            <span class="remaining">剩余启停次数<strong>{{auth()->guard('company')->user()->stop_number}}</strong>次</span>
                            <span class="remaining">你的会员剩余天数是：<strong>{{auth()->guard('company')->user()->surplus_day}}</strong>天</span>
                        @endif

                    </div>
                    <div class="line m60"></div>
                    <div class="recording">
                        <h2>会员启停记录</h2>
                    </div>
                    <div class="listmenu recordinglist">
                        <ul class="one">
                            <li class="p1"></li>
                            <li class="p400">启停时间</li>
                            <li class="p400">会员状态</li>
                        </ul>
                        @if(count($companyStartStop)>0)
                            @foreach($companyStartStop as $v)
                                <ul class="srecord">
                                    <li class="p1"></li>
                                    <li class="p400">{{$v->created_at}}</li>
                                    @if($v->status==1)
                                        <li class="p400 statr">开启</li>
                                    @else
                                        <li class="p400 stop">关闭</li>
                                    @endif
                                </ul>
                            @endforeach
                        @else
                            <div class="nullcon">抱歉，您还没有启停记录.</div>
                        @endif
                    </div>
                </div>

            </div>
        </div>


    </div>
@endsection
@section('footerjs')
    @parent
    <script>
        //设置启停
        var startStopSing = true;//标记为了重复提交
        function startStop(msg, s_type){
            layer.confirm(msg, {
                title: ['温馨提示'], //按钮
                btn: ['确定', '取消'] //按钮
            }, function(){
                if(startStopSing){
                    startStopSing = false;
                    $.post("/company/set_start_stop", {
                        's_type': s_type,
                        '_token': "{{csrf_token()}}"
                    }, function(data){
                        if(data.status == 0){
                            layer.msg(data.msg, {icon: 6, time: 2000});
                            startStopSing = true;
                            location = '/company/start_stop';
                        }else{
                            layer.msg(data.msg, {icon: 5});
                            startStopSing = true;
                        }
                    });
                }
            });
        }
        $("#leftnav_order").addClass("active");
    </script>
@endsection